﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

using Fusion;

namespace Fusion.Interface
{
	public class Panel : Control
	{
		#region Attributes

		public List<Control> controls = new List<Control>();

		#endregion

		#region Constructors

		/// <summary>Creates a panel</summary>
		/// <param name="origin">The top-left corner of the panel</param>
		/// <param name="size">The width and height of the panel</param>
		public Panel( Vector2 origin, Vector2 Size )
		{
			position = origin;
			size = Size;

			drawBorder = true;
		}

		#endregion

		#region Methods

		/// <summary> Adds a new child button to this dialog </summary>
		/// <param name="button">The button to add</param>
		public Control Add( Control control )
		{
			control.container = this;
			controls.Add( control );
			return control;
		}

		/// <summary>Provides input to the panel and it's contents</summary>
		/// <param name="cursor">The cursor to take input from</param>
		public override void Input( Vector2 cursor, bool button )
		{
			if( disabled )
				return;

			base.Input( cursor, button );

			foreach( Control control in controls )
				control.Input( cursor, button );
		}

		public override void Update()
		{
			base.Update();

			foreach( Control control in controls )
				control.Update();
		}

		/// <summary> Renders the button </summary>
		public override void Draw()
		{
			base.Draw();

			foreach( Control control in controls )
				control.Draw();
		}

		#endregion
	}
}
